#ifndef GAMEENGINE_GAMEPLAY_STATES_LOCK_STATE_H
#define GAMEENGINE_GAMEPLAY_STATES_LOCK_STATE_H

#include <GameEngine/Gameplay/gameplay_settings.h>

#include <QtCore/QList>


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif

class ObjectInventory;
class ObjectContainer;

//=================================================================================


//! The lock state of an item (typically, this state applies to doors and containers)
/*!
 *  The lock state of an object determines whether this object can be opened by an
 *  actor. Unlocked objects can be opened by anybody; if the object is locked, it
 *  can still be opened by an actor who holds the correct key.
 *
 @todo Future versions will manage more intrusive ways to open objects, e.g., by
       applying brute force to the lock or by using a lock picking strategy
 */
class _Gameplay_decl LockState {

public:
	//! The lock state of the object
	enum State {
		//! The object is locked and cannot be opened, except possibly by someone who owns the key
		Locked,
		//! The object is unlocked and can be opened by anybody
		Unlocked
	};

	LockState(State state = Unlocked);
	LockState(const LockState& rhs);
	LockState& operator=(const LockState& rhs);
	virtual ~LockState();

	bool can_open(ObjectContainer* container) const;
	bool can_open(const QList<ObjectInventory*>& objects) const;

	State state() const;
	State& state();

	bool add_keys(const QList<ObjectInventory*>& keys);
	bool add_key(ObjectInventory* key);
	bool remove_keys(const QList<ObjectInventory*>& keys);
	bool remove_key(ObjectInventory* key);
	bool find_key(const ObjectInventory* key) const;
	QList<ObjectInventory*>* keys() const;

private:
	//! Current lock state of the object
	State state_;

	//! Keys to open the lock, if any
	QList<ObjectInventory*>* keys_;
};


#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#endif
